package com.samoiloff.ui.scroll.resize {
	import com.samoiloff.ui.scroll.resize.view.ResizeScrollView;
	import flash.events.Event;
	import com.samoiloff.ui.scroll.resize.model.ResizeScrollModel;
	import com.samoiloff.ui.scroll.resize.controller.ResizeScrollController;
	import com.samoiloff.framework.AbstractComponent;

	/**
	 * @author Samoiloff
	 */
	public class ResizeScroll extends AbstractComponent {
		
		public function ResizeScroll() {
			super();
			
			_model.addEventListener(ResizeScrollModel.SCROLL_POSITION_CHANGED, onScrollPositionChanged);
		}
		
		
		override protected function getModelClass() : Class {
			return ResizeScrollModel;
		}
		
		override protected function getViewCls() : Class {
			return ResizeScrollView;
		}
		
		override protected function getControllerCls() : Class {
			return ResizeScrollController;
		}

		private function onScrollPositionChanged(event: Event): void {
			dispatchEvent(new Event(Event.SCROLL));
		}

		//scrollPosition
		public function get scrollPosition():Number {
			return getModel().scrollPosition ;
		}
		
		public function set scrollPosition(scrollPosition:Number):void {
			getModel().scrollPosition = scrollPosition;
		}
		//maxScrollPosition
		public function get maxScrollPosition():Number {
			return getModel().maxScrollPosition;
		}
		
		public function set maxScrollPosition(maxScrollPosition:Number):void {
			getModel().maxScrollPosition = maxScrollPosition;
		}
		//height
		override public function get height(): Number {
			return getModel().height;
		}
		
		override public function set height(value: Number): void {
			getModel().height = value;
		}

		private function getModel():ResizeScrollModel {
			return _model as ResizeScrollModel;
		}
	}
}
